﻿using BCC.Model.Enumeration;
using BCC.Model.Monitor;
using System;
using System.Collections.Generic;
using System.Text;

namespace BCC.VB.ViewCommunication
{
    public static class Monitor
    {
        public static event EventHandler<MessageArgs> PartEvent;//定义在Monitor中的一个事件，参数是MessageArgs对象

        public static void InFunction(string message,string time)
        {
            var messageArg = new MessageArgs(message,time)
            {
                TxtMessage = message
            };
            if (PartEvent != null)//如果mainwindow构造函数中给PartEvent注册了函数就不为null
            {
                PartEvent(null, messageArg);//触发事件，执行所有注册过的函数
            }
        }

        public static void MonitorCenter(string s,string time)
        {
            InFunction(s, time);//在外部类中修改TextBlock的Text
        }


        public static event EventHandler<MessagePicArgs> PartPicEvent;//定义在Monitor中的一个事件，参数是MessageArgs对象

        public static void InPicFunction(byte[] imgmessage, string time, ImageType imageType)
        {
            var messageArg = new MessagePicArgs(imgmessage, time, imageType)
            {
                imgMessage = imgmessage,
                TxtTime = time,
                imageType = imageType
            };
            if (PartPicEvent != null)//如果mainwindow构造函数中给PartEvent注册了函数就不为null
            {
                PartPicEvent(null, messageArg);//触发事件，执行所有注册过的函数
            }
        }

        public static void MonitorPicCenter(byte[] s, string time, ImageType imageType)
        {
            InPicFunction(s, time, imageType);//在外部类中修改TextBlock的Text
        }
    }
}
